package com.gotokeep.keep.composition.renderer;

import android.media.MediaCodec;
import android.media.MediaFormat;
import android.util.Log;

import com.gotokeep.keep.composition.MediaExportConfiguration;

import java.io.IOException;

/**
 * @author xana/cuixianming
 * @version 1.0
 * @since 2018-05-04 16:47
 */
class AudioMediaRenderer extends MediaRenderer {

    @Override
    public void prepareEncoder(MediaExportConfiguration configuration) throws IOException {
        super.prepareEncoder(configuration);

        MediaFormat audioFormat = MediaFormat.createAudioFormat(configuration.getAudioMimeType(),
                configuration.getSampleRate(), configuration.getChannelCount());
        audioFormat.setInteger(MediaFormat.KEY_AAC_PROFILE, configuration.getAacProfile());
        audioFormat.setInteger(MediaFormat.KEY_BIT_RATE, configuration.getAudioBitRate());
        if (verbose) {
            Log.v(TAG, "Encoder audio format: " + audioFormat);
        }
        encoder = MediaCodec.createEncoderByType(configuration.getAudioMimeType());
        encoder.configure(audioFormat, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
        encoder.start();
    }

    @Override
    public long render(long presentationTimeUs) {
        return 0;
    }
}
